Encoding:

P32A

001000

rt

rs

rd

SUBQH.PH

0

1001001

101

P32A

001000

rt

rs

rd

SUBQH_R.PH

1

1001001

101

6

5

5

5

1

7

3

Format:

SUBQH[_R].PH 

Subtract Fractional Halfword Vectors And Shift Right to Halve Results

SUBQH.PH     rd, rs, rt

DSP-R2

Subtract Fractional Halfword Vectors And Shift Right to Halve Results

SUBQH_R.PH   rd, rs, rt

DSP-R2

Subtract Fractional Halfword Vectors And Shift Right to Halve Results

Purpose:

Subtract Fractional Halfword Vectors And Shift Right to Halve Results

Element-wise fractional subtr action of halfw ord vectors, with a right shift by one bit to halve each result, with optional rounding.

Description:

rd = round((rs31..16 - rt31..16) >> 1) || round((rs15..0 - rt15..0) >> 1)

Each element from the tw o halfword values in register rt is subtracted from the corresponding halfword element in register rs to create an interim 17-bit result.

In the non-rounding instruction variant, each interim result is then shifted right by one bit before being written to the corresponding halfword element of destination register rd.

In the rounding version of the instruction, a v alue of 1 is added at the least-significant bit position of each interim result; the interim result is then right-shifted by one bit and written to the destination register.

This instruction does not modify the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

ADDQH.PH
   ValidateAccessToDSP2Resources()
   tempB15..0 = rightShift1SubQ16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = rightShift1SubQ16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]31..0 = tempB15..0 || tempA15..0
ADDQH_R.PH
   ValidateAccessToDSP2Resources()
   tempB15..0 = roundRightShift1SubQ16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = roundRightShift1SubQ16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]31..0 = tempB15..0 || tempA15..0
function rightShift1SubQ16( a15..0 , b15..0 )
   temp16..0 = (( a15 || a15..0 ) - ( b15 || b15..0 ))
   return temp16..1
endfunction rightShift1SubQ16
function roundRightShift1SubQ16( a15..0 , b15..0 )
   temp16..0 = (( a15 || a15..0 ) - ( b15 || b15..0 ))
   return temp16..1
endfunction roundRightShift1SubQ16

Exceptions:

Reserved Instruction, DSP Disabled